#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

const int N = 2e5 + 10;
const ll inf = 1e18;

template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }
template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }

struct convex_hull { 
	struct dot {
		ll x, y;
		dot(ll _x = 0, ll _y = 0) : x(_x), y(_y) { }
		friend dot operator - (dot a, dot b) { return dot(a.x - b.x, a.y - b.y); }
		ll operator [](ll k) { return k * x + y; }
	} stk[N];
	int top;
	db slope(dot a) { return 1. * a.y / a.x; }
	convex_hull() { top = 0; }
	void ins(ll x, ll y) {
		dot cur(x, y); while(top > 1 && slope(stk[top - 1] - stk[top]) <= slope(stk[top - 1] - cur)) top--;
		stk[++top] = cur;
	} // 插入的时候是 dep 递减的，因此是维护上凸壳。
	ll query(ll k) {
		if(!top) return inf;
		int l = 1, r = top - 1; ll ans = stk[top][k];
		while(l <= r) {
		 	int mid = l + r >> 1; chkmin(ans, stk[mid][k]);
		 	if(slope(stk[mid] - stk[mid + 1]) > -k) l = mid + 1;
		 	else r = mid - 1;
		}
		return ans;
	}
} H;

int n, testcase, f[N], p[N], siz[N], son[N], rt;
ll s[N], q[N], l[N], dep[N], ans[N], tdep;
bool v[N];
vec G[N];
vector < pair < ll, int > > pot;

void fsz(int x, int p) { son[x] = 0; siz[x] = 1; for(auto y : G[x]) if(!v[y] && y ^ p) fsz(y, x), siz[x] += siz[y], chkmax(son[x], siz[y]); }
void frt(int x, int p, int tz) { for(auto y : G[x]) if(!v[y] && y ^ p) frt(y, x, tz); chkmax(son[x], tz - siz[x]); (!rt || son[x] < son[rt]) && (rt = x); }

void dfs(int x, int p) {
	if(dep[x] - l[x] <= tdep) pot.eb(tdep - dep[x] + l[x], x);
	for(auto y : G[x]) if(!v[y] && y ^ p) dfs(y, x); 
}

void tcalc(int x, int pre) {
	for(int y = f[x]; y ^ pre; y = f[y]) if(dep[x] - dep[y] <= l[x]) chkmin(ans[x], ans[y] + (dep[x] - dep[y]) * p[x] + q[x]); else break;
	tdep = dep[x]; pot.clear(); H.top = 0; for(auto y : G[x]) if(!v[y]) dfs(y, x);
	sort(pot.begin(), pot.end()); int cur = x;
	for(auto v : pot) {
		ll lim; int y; tie(lim, y) = v; // 之前写成了： int lim; ll y; /kk
		while(cur ^ pre && dep[x] - dep[cur] <= lim) H.ins(dep[cur], ans[cur]), cur = f[cur];
		chkmin(ans[y], H.query(-p[y]) + q[y] + dep[y] * p[y]);
	}
}
// 一定要双向边，不然不好向上找重心。
void divide(int x, int p) {
	rt = 0; fsz(x, 0); frt(x, 0, siz[x]); x = rt; v[x] = true;
	if(f[x] ^ p) divide(f[x], p);
	tcalc(x, p); for(auto y : G[x]) if(!v[y]) divide(y, x);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, testcase = in; 
	rep(i, 2, n) f[i] = in, s[i] = lin, p[i] = in, q[i] = lin, l[i] = lin, G[f[i]].eb(i), G[i].eb(f[i]), dep[i] = dep[f[i]] + s[i], ans[i] = 1e18;
	divide(1, 0); rep(i, 2, n) printf("%lld\n", ans[i]);
	return 0;
}
